
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<link href="../css/main.css" type="text/css" rel="stylesheet" />
		<link href="../css/dialog.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="../datePicker/WdatePicker.js"></script>
		<title></title>
		
	</head>
	<body>
		<div class="main_frame">
			<div class="position_div">
				<img src="../images/position_icon.png" />
				<i>销售管理</i><i>&gt;&gt;</i><i>已完成订单</i>
			</div>
			<div class="right_div">
				<div class="search_div">
				
					
					<div class="label_div">
						<label class="text_label">订单编号：</label>
						<input type="text" class="input_search"  id="qry_order" placeholder="请输入"/>
					</div>
					
					<div class="label_div">
						<label class="text_label">用户名称：</label>
						<input type="text" class="input_search" placeholder="请输入" id="qry_user" />
					</div>
					<div class="label_div">
						<label class="text_label">经销商：</label>
						<input type="text" class="input_search" placeholder="请输入" id="qry_de" />
					</div>
					
					
				
				
					
					<div class="done_div">
						<button class="btn_common1 title_div2"  onclick="qryItemListBtn()">
							<i></i>搜索
						</button>
						
					</div>
                    <div class="cl">&nbsp;</div>
				</div>
				<table class="table_list">
					<tr>
						<th width="6%">序号</th>
						<th width="10%">订单编号</th>
						<th width="10%">设备名称</th>
						<th width="10%">设备代码</th>
						<th width="12%">设备类型</th>
						<th width="10%">经销商</th>
						<th width="10%">关联用户</th>
						<th width="12%">要货时间</th>
						<th width="8%">状态</th>
						
						<th class="last_td">操作</th>
					</tr>
					<tbody id="listbox1">
					</tbody>
				</table>
				<div class="turn_page" style="display:none">
				   <div class="main_page" id="pageCon">
					   <a href="javascript:void(0)" class="first_a" id="firstPage"></a>
					   <a href="javascript:void(0)" class="up_a" id="prev"></a>    	
					   <a href="javascript:void(0)" class="next_a" id="next"></a>
					   <a href="javascript:void(0)" class="last_a" id="lastPage"></a>
					   <input id="page_num_input" style="width:40px;" type="text" onblur="checkValue(this);" onkeyup="value=value.replace(/\D/g,'')"/>
					   <button type="button" class="num_input" id="go_num_input">跳转</button>
					   <b class="page_text">当前<i><em id="nowpage"></em>/<em id="totalpage"></em></i>页，总数<i id="totalNum"></i>条</b>    	
				   </div>
				</div>
				
				
				
				
				<div class="opacity_div" style="display: none;"></div>
				<div class="bookDetail" style="display: none;top:150px;">
					<div class="prop_top">
						<i>处理</i>
						<a href="javascript:void(0)" class="close_icon"><img src="../images/close_icon.png"></a>
					</div>
					<div class="bookdetail_box">
					<form action="" id="form">
						<div class="blank_div"></div>
						<input type="hidden" class="input_search width_input" name="id" value="0"  id="order_id"/>
						<div class="blank_div"></div>
						
						<div class="blank_div"></div>
						<label class="text_label label_width">状态：</label>
						<div class="drop_frame">
								<i class="text_i" data-status="0" >请选择</i>
								<span class="span_arrow"></span>
								<input type="hidden" name="status" >
								<ul class="choose_ul ">
								
								<li>
									<a href="javascript:void(0)" class="choose_a" data-status="2">配件采购</a>
								</li>
								<li>
									<a href="javascript:void(0)" class="choose_a" data-status="3">图纸设计</a>
								</li>
								<li>
									<a href="javascript:void(0)" class="choose_a" data-status="4">软件设计</a>
								</li>
								<li>
									<a href="javascript:void(0)" class="choose_a" data-status="5">硬件装配</a>
								</li>
								<li>
									<a href="javascript:void(0)" class="choose_a" data-status="6">出库</a>
								</li>
								<li>
									<a href="javascript:void(0)" class="choose_a" data-status="7">装运</a>
								</li>
								<li>
									<a href="javascript:void(0)" class="choose_a" data-status="8">已完成</a>
								</li>
								</ul>
						</div>
						
					    
					</form>
					<div class="blank_div"></div>
					<div class="blank_div"></div>
					<div class="bottom_donebtn width_div">
						<button class="btn_common2"  onclick="itemFormSubmit()">提交</button>
						<button class="btn_common1" onclick="edit_cancel()">取消</button>	
					</div>
					
					</div>
				</div>
				
				
			
			
				
				
				
			</div>
		</div>
		<script type="text/javascript" src="../js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/dialog.js"></script>
		<script type="text/javascript" src="../js/jquery-data.js"></script>
		<script type="text/javascript">
			var yema=1;
			var pagelen=10;
			var totalPage=0;   
			function qryList(){		
				qryItemList();
			}
			var status_obj= {2:'配件采购',3:'图纸设计',4:'软件设计',5:'硬件装配',6:'出库' ,7:'装运',8:'已完成'};
			$(document).ready(function(){
				getDictionaryList();
				getModelList();
				qryList();
			});
			function qryList(){
				qryItemList();
			}
			function qryItemListBtn(){
				 yema=1;
				qryItemList();
			}
			function qryItemList(){
				$.ajax({
					url: 'qryOrderList', 
					type: 'POST',
					data:{orderNo:$("#qry_itemId").val(),
						userName:$("#qry_user").val(),
						orderNo:$("#qry_order").val(),
						dealerName:$("#qry_de").val(),
						status:8,
						yema:yema,length:pagelen},
					async: false,
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						
						if(result.resultCode==1000){
							var items=result.returnObject.pageList;
							if (items && items.length > 0) {
								var rlist="";
								var item ;
								
								$.each(items,function(i){
									item = items[i];
									rlist+='<tr data-status ="'+ item.id+'"><td>'
										+ (i+1+length*(result.returnObject.curPage-1))
										+ '</td><td>' 
										+ item.orderNo
										+ '</td><td>' 
										+ item.deviceName
										+ '</td><td>' 
										+ item.deviceNo
										+ '</td><td>' 
										+ item.typeName
										+ '</td><td>' 
										+ item.dealerName
										+ '</td><td>' 
										+ item.userName
										+ '</td><td>' 
										+ formatToDate(item.requireTime)
										+ '</td><td>'
										+ status_obj[item.status]
										+'</td><td class="last_td">'
										+ '<a class="mod" title="退回" href="javascript:void(0);" onclick="toEditForm(this)">退回</a>'
										
										+ '</td></tr>';
								});
								$("#listbox1").html(rlist);
								totalPage=result.returnObject.totalPage;
								$("#nowpage").html(result.returnObject.curPage);
								$("#totalpage").html(totalPage);
								$("#totalNum").html(result.returnObject.totalNum);
								$(".turn_page").show();
							}else{
								$("#listbox1").html("");
								$(".turn_page").hide();
							}
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});
			}
			
			var url_ = "addSalesOrder.do";
			
			function toAddForm(){
				$(".opacity_div,.bookDetail").show();	
				url_ = "addSalesOrder.do";
				$("#form").clearForm();
			}

			
			function itemFormSubmit(){
			//	console.log($("#form").serialize());
					if($("#form").checkhaveNull()){
					return;
				}
				operateObject(url_,$("#form").serialize(),function(){edit_cancel();});
				//return;
				
			}
			
			
			function toEditForm(obj){
				var id = $(obj).parents("tr").attr("data-status");
				toAddForm();
				url_ = "handleSalesOrder.do";
				$("#order_id").val(id);
				//operateObject("handleSalesOrder.do",{"id":id,"status":2},function(){edit_cancel();});
				
			}
			
		
			
			function edit_cancel(){
				$(".opacity_div,.bookDetail").hide();
			}
			
			function getDictionaryList(){
				
				$.ajax({
					url: '/boilerCloud/dictionary/getDictionaryList.do', 
					type: 'POST',
					async: false,
					traditional:true,
					data:{type:2},
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						if(result.resultCode==1000){
							//console.log(result.returnObject);
							var items = result.returnObject;
							var item;
							var html_items = "";
							
							if(items){
								for(var i=0;i<items.length;i++){
									item = items[i];
									html_items  += '<li><a href="javascript:void(0)" class="choose_a" data-status="'
									+items[i].id+'" >'+ items[i].name+'</a></li>';		
								}
							}
							$(".items").html(html_items);
							$(".qry_items").html('<li><a href="javascript:void(0)" class="choose_a" data-status="0" >全部</a></li>'+html_items);
							
							
							
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});	
			}

			function getModelList(){
				//alert($(obj).attr("data-status"));
				$("#typeId").attr("data-status",0).html("请选择")
				$.ajax({
					url: '/boilerCloud/front/getAppUserList.do', 
					type: 'POST',
					async: false,
					traditional:true,
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						if(result.resultCode==1000){
							//console.log(result.returnObject);
							var items = result.returnObject;
							var item;
							var html_items = "";
							
							if(items){
								for(var i=0;i<items.length;i++){
									item = items[i];
									html_items  += '<li><a href="javascript:void(0)" class="choose_a" data-status="'
									+items[i].id+'">'+ items[i].name+'</a></li>';		
								}
							}
							$(".type_html").html(html_items);
							
							
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});	
			}
			
				
		</script>
	</body>
</html>
